package
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.geom.Point;

	public class GMDefault implements IGameMode
	{
		private var m_currentlySelected:ISelectable = new EmptySelectable();
		
		public function GMDefault()
		{
			
		}

		
		public function onMouseMove(me:MouseEvent):void{
			var currentMousePosition:Point = new Point(me.stageX, me.stageY);
			var selectedObject:ISelectable = Game.instance.findSelectedObject(currentMousePosition);
			if(m_currentlySelected){
				m_currentlySelected.highlite(false);
			}
			
			if(selectedObject != null){	
				selectedObject.highlite(true);
				m_currentlySelected = selectedObject;
				if(selectedObject is ITooltipable){
					Game.instance.hud.showTooltip((selectedObject as ITooltipable).getTooltip(), currentMousePosition);
				}
			} else {
				m_currentlySelected = null;
				Game.instance.hud.hideTooltip();
			}
		}
		
		public function onMouseUp(me:MouseEvent):void{
			if(m_currentlySelected != null){
				Game.instance.onClick(m_currentlySelected);
			} else {
				Game.instance.mall.closeAllMenus();
			}
		}
		
		public function onMouseDown(me:MouseEvent):void{

		}
		
		public function cleanup():void{}
	}
}